Skip to content

[PWGJE] pTHat handling, remove HepMCXSections dependency, add R-d…#15284

Draft
joonsukbae wants to merge 2 commits intoAliceO2Group:masterfrom
joonsukbae:fix/pthat-matching-cleanup
Draft

[PWGJE] pTHat handling, remove HepMCXSections dependency, add R-d…#15284
joonsukbae wants to merge 2 commits intoAliceO2Group:masterfrom
joonsukbae:fix/pthat-matching-cleanup

Conversation

@joonsukbae
Copy link
Contributor

@joonsukbae joonsukbae commented Mar 5, 2026

…ependent matching

  • trackEfficiency: Remove HepMCXSections/JMcCollisionPIs table subscriptions from all MC processes. Use ptHard() from JMcCollisions with weight-based fallback. Add applyRCTSelections configurable. Remove getPtHatFromHepMCXSection configurable.
  • jetSpectraCharged: Pass pTHat as parameter to fill functions. Fix pTHatMaxMCDpTHatMaxMCP bug. Change MCD weighted subscriptions to JetCollisionsMCD. Add applyRCTSelections configurable.
  • Jet matching (all 6 headers + JetMatchingUtilities.h): Add per-R matching distance override (jetRadiiForMatchingDistance + maxMatchingDistancePerJetR) on top of existing maxMatchingDistance fallback. Backward compatible — empty per-R vectors (default) give identical results.

…ependent matching

- trackEfficiency: Remove HepMCXSections and JMcCollisionPIs table
  subscriptions from all MC processes; use ptHard() from JMcCollisions
  with weight-based fallback. Add applyRCTSelections configurable.
- jetSpectraCharged: Pass pTHat as parameter to fill functions instead
  of computing internally; fix pTHatMaxMCD->pTHatMaxMCP bug in
  fillGeoMatchedAreaSubHistograms; change MCD weighted process
  subscriptions to JetCollisionsMCD for mcCollision() access.
- All jet matching tasks: Replace single maxMatchingDistance with per-R
  configurables (jetRadiiForMatchingDistance + maxMatchingDistancePerJetR)
  for R-dependent geometric matching distance. Applied to jetMatchingMC,
  jetMatchingMCSub, jetMatchingSub, jetMatchingDuplicates,
  jetSubstructureMatching, and jetSubstructureMatchingSub.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joonsukbae joonsukbae force-pushed the fix/pthat-matching-cleanup branch from 7ebc7cc to 35b52a7 Compare March 5, 2026 22:34
Copy link
Collaborator

@nzardosh nzardosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR Joonsuk. Please make the changes and then locally test that you get the same results.
Also in the future if you would like to make changes to the core tasks, please discuss them in advance first
Thanks

}
std::tie(baseToTagMatchingGeoIndex, tagToBaseMatchingGeoIndex) = MatchJetsGeometrically(jetsBasePhi, jetsBaseEta, jetsTagPhi, jetsTagEta, maxMatchingDistance); // change max distnace to a function call
float effectiveMatchingDistance = maxMatchingDistance;
for (std::size_t i = 0; i < jetRadiiForMatchingDistance.size() && i < maxMatchingDistancePerJetR.size(); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here i would only check one of i < jetRadiiForMatchingDistance.size() or i < maxMatchingDistancePerJetR.size() since we constrain them to be the same

jetsTagGlobalIndex.emplace_back(jetTag.globalIndex());
}
std::tie(baseToTagMatchingGeoIndex, tagToBaseMatchingGeoIndex) = MatchJetsGeometrically(jetsBasePhi, jetsBaseEta, jetsTagPhi, jetsTagEta, maxMatchingDistance); // change max distnace to a function call
float effectiveMatchingDistance = maxMatchingDistance;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here take the first one in the list so we can get rid of maxMatchingDistance as variable. So do
float effectiveMatchingDistance = maxMatchingDistance[0];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will break if an empty list is given at runtime but i think thats good. or where you do the LOGP fatal you can also check that the lists are not empty

}

template <typename T, typename U>
void MatchGeo(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector<std::vector<int>>& baseToTagMatchingGeo, std::vector<std::vector<int>>& tagToBaseMatchingGeo, float maxMatchingDistance)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the variable float maxMatchingDistance,

@@ -35,6 +35,8 @@ struct JetMatchingDuplicates {
o2::framework::Configurable<bool> doMatchingPt{"doMatchingPt", true, "Enable pt matching"};
o2::framework::Configurable<bool> doMatchingHf{"doMatchingHf", false, "Enable HF matching"};
o2::framework::Configurable<float> maxMatchingDistance{"maxMatchingDistance", 0.24f, "Max matching distance"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this variable everywhere

o2::framework::Configurable<bool> doMatchingHf{"doMatchingHf", false, "Enable HF matching"};
o2::framework::Configurable<float> maxMatchingDistance{"maxMatchingDistance", 0.24f, "Max matching distance"};
o2::framework::Configurable<std::vector<double>> jetRadiiForMatchingDistance{"jetRadiiForMatchingDistance", {}, "Jet R values for per-R matching distance override, e.g. {0.2, 0.4, 0.6}"};
o2::framework::Configurable<std::vector<double>> maxMatchingDistancePerJetR{"maxMatchingDistancePerJetR", {}, "Max matching distance for each R in jetRadiiForMatchingDistance, e.g. {0.12, 0.24, 0.36}"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you checked up in previous analysis notes that these are the correct default values? Please also find the appropriate ones for R=0.3 and R=0.5 and add them too

}
std::tie(baseToTagMatchingGeoIndex, tagToBaseMatchingGeoIndex) = MatchJetsGeometrically(jetsBasePhi, jetsBaseEta, jetsTagPhi, jetsTagEta, maxMatchingDistance); // change max distnace to a function call
float effectiveMatchingDistance = maxMatchingDistance;
for (std::size_t i = 0; i < jetRadiiForMatchingDistance.size() && i < maxMatchingDistancePerJetR.size(); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole addition could be moved to line 314, after these :
for (auto jetR : jetsR) {
std::vector jetsBasePhi;
std::vector jetsBaseEta;
std::vector jetsBaseGlobalIndex;
std::vector baseToTagMatchingGeoIndex;
std::vector tagToBaseMatchingGeoIndex;

Because that way then you evaluate it once per jetR and you dont have to do the evaluation each time per jet


template <typename T, typename U>
void MatchGeo(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector<std::vector<int>>& baseToTagMatchingGeo, std::vector<std::vector<int>>& tagToBaseMatchingGeo, float maxMatchingDistance)
void MatchGeo(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::vector<std::vector<int>>& baseToTagMatchingGeo, std::vector<std::vector<int>>& tagToBaseMatchingGeo, float maxMatchingDistance, std::vector<double> const& jetRadiiForMatchingDistance = {}, std::vector<double> const& maxMatchingDistancePerJetR = {})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need to initialise with empty vectors. Its good to make sure these vectors are always given to the function and no default empty value is taken

@nzardosh nzardosh marked this pull request as draft March 6, 2026 09:39
- Remove maxMatchingDistance from all headers and JetMatchingUtilities.h
- Non-empty defaults: {0.3, 0.4, 0.5} -> {0.18, 0.24, 0.30}
- init() fatal on empty/mismatched vectors
- Runtime fatal if jet R not in configured list
- Per-R lookup once per R, not per jet
- No default empty vectors in function signatures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joonsukbae
Copy link
Contributor Author

Thanks for the PR Joonsuk. Please make the changes and then locally test that you get the same results. Also in the future if you would like to make changes to the core tasks, please discuss them in advance first Thanks

Dear Nima,
Thanks for the review! I've addressed the comments:

  • Removed maxMatchingDistance from all 6 matching headers and JetMatchingUtilities.h
  • Per-R matching distance with non-empty defaults: {0.3, 0.4, 0.5} → {0.18, 0.24, 0.30}
  • Fail-early strategy: init() fatal on empty/mismatched vectors, runtime fatal if jet R not configured, no default empty
    vectors in function signatures
  • Per-R lookup moved to once per R, not per jet

Tested locally: ran full pipeline (jet finding + matching + trackEfficiency + jetSpectraCharged) on LHC25a2. All 125
histograms identical between pre-PR and post-PR code.

Understood — I'll discuss changes to core tasks in advance before making edits. Thanks for the guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants